package com.ruoyi.prodata;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wbs.service.IContractorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 24822
 */
@RestController
@RequestMapping("/prodata/paymentStatistics")
public class PaymentStatisticsController extends BaseController {

    @Autowired
    private IContractorService contractorService;

    @GetMapping("/list")
    public AjaxResult list(Long projectId){
        List<Map<String,Object>> list = contractorService.list(projectId);
        List<String> nameList = new ArrayList<>();
        List<String> payList = new ArrayList<>();
        List<String> payPercentList = new ArrayList<>();
        list.forEach(map->{
            nameList.add(map.get("name").toString());
            payList.add(map.get("pay").toString());
            payPercentList.add(map.get("payPercent").toString());
        });
        Map<String,Object> result = new HashMap<>();
        result.put("nameList",nameList);
        result.put("payList",payList);
        result.put("payPercentList",payPercentList);
        return AjaxResult.success(result);
    }

}
